home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / pleas / ole / visio / network / netdiag.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-05-18  |  4.9 KB  |  128 lines

  1. VERSION 2.00
  2. Begin Form frmMainForm 
  3.    BackColor       =   &H0080FFFF&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Network Diagramming"
  6.    ClientHeight    =   1905
  7.    ClientLeft      =   780
  8.    ClientTop       =   1800
  9.    ClientWidth     =   5115
  10.    Height          =   2595
  11.    Icon            =   NETDIAG.FRX:0000
  12.    Left            =   720
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    ScaleHeight     =   1905
  16.    ScaleWidth      =   5115
  17.    Top             =   1170
  18.    Width           =   5235
  19.    Begin CommonDialog ctlCDialog 
  20.       Left            =   480
  21.       Top             =   600
  22.    End
  23.    Begin Menu mnuFile 
  24.       Caption         =   "&File"
  25.       Begin Menu mnuFileNewDBase 
  26.          Caption         =   "&New Database..."
  27.       End
  28.       Begin Menu mnuFileOpen 
  29.          Caption         =   "&Open Database..."
  30.       End
  31.       Begin Menu mnuFileSep1 
  32.          Caption         =   "-"
  33.       End
  34.       Begin Menu mnuFileExit 
  35.          Caption         =   "E&xit"
  36.       End
  37.    End
  38. '------------------------------------------------------------------------------
  39. '------------------------------------------------------------------------------
  40. '--                        Network Diagramming Example
  41. '--                       (C)1993 Shapeware Corporation
  42. '--   File Name : netdiag.frm
  43. '-- Description :
  44. '------------------------------------------------------------------------------
  45. '------------------------------------------------------------------------------
  46. 'This file contains sample code for using Visual Basic and OLE 2.0 to
  47. 'automatically create a Visio network diagram from a Microsoft Access
  48. 'database.
  49. 'IMPORTANT:  NETVB.ZIP is ONLY a sample, not a released product.  It was
  50. 'not extensively tested, and has no guarantee.  In addition, we do not provide
  51. 'documentation or support for this file.
  52. 'After you download and unzip the file, read the file "abstract.wri" to get
  53. 'more information about what you need before running the file.
  54. 'To run the file*, open your Windows File Manager, go to the directory where
  55. 'you placed the unzipped files, and double-click the file "netdiag.mak."  This
  56. 'will open Visual Basic.  Press F5 to run the program.  The program will run,
  57. 'and from its File menu, choose Open Database.  Then choose "network.mdb"
  58. 'which is included in NETVB.ZIP and watch your blank Visio drawing page
  59. 'turn into a basic network diagram!
  60. '*It doesn't matter if you already have Visio running.  If it is, that instance
  61. 'will be used.  If not, the program will start it.
  62. Option Explicit
  63. Sub mnuFileExit_Click ()
  64. '----------------------------------------
  65. '--- mnuFileExit_Click ------------------
  66. '--   Handles request for exit.  We prompt before exiting.
  67.     Dim strMsg As String
  68.     strMsg = "Are you sure you want to quit?"
  69.     If MsgBox(strMsg, MB_ICONEXCLAMATION Or MB_YESNO, "Exit") = IDYES Then
  70.         End
  71.     End If
  72. End Sub
  73. Sub mnuFileNewDBase_Click ()
  74. '----------------------------------------
  75. '--- mnuFileNewDBase_Click --------------
  76. '--   Handles the user's request to build a blank database.
  77.     On Error GoTo lblNewDBaseCatchCancelErr
  78.     Dim strFileName As String
  79.     ctlCDialog.DialogTitle = "Create Blank Database"
  80.     ctlCDialog.CancelError = True
  81.     ctlCDialog.Flags = OFN_HIDEREADONLY Or OFN_OVERWRITEPROMPT
  82.     ctlCDialog.Filter = "Access Files (*.mdb)|*.mdb"
  83.     ctlCDialog.DefaultExt = "mdb"
  84.     ctlCDialog.Action = 2
  85.     strFileName = ctlCDialog.Filename
  86.     On Error GoTo lblKillCatch
  87.     Kill strFileName
  88.     SetMousePointer MP_WAIT
  89.     CreateBlankDatabase strFileName
  90.     SetMousePointer MP_NORMAL
  91.     MsgBox strFileName & " Created.", MB_ICONINFORMATION, ""
  92.     Exit Sub
  93. lblNewDBaseErr:
  94.     MsgBox "Error creating blank database." & Chr(13) & Chr(10) & Error
  95.     Exit Sub
  96.     Resume Next
  97. lblNewDBaseCatchCancelErr:
  98.     Exit Sub
  99.     Resume Next
  100. lblKillCatch:
  101.     Resume Next
  102. End Sub
  103. Sub mnuFileOpen_Click ()
  104. '----------------------------------------
  105. '--- mnuFileOpen_Click ------------------
  106. '--   The process for creating a network diagram requires we first prompt for
  107. '-- an Access database name.  If the user selects a file we then verify it
  108. '-- is OK for diagramming (ValidDatabase) and if so we create the diagram.
  109.     Dim strFileName As String
  110.     On Error GoTo lblFileOpenErr
  111.     ctlCDialog.DialogTitle = "Open Network Database"
  112.     ctlCDialog.Filter = "Access Files (*.mdb)|*.mdb"
  113.     ctlCDialog.CancelError = True
  114.     ctlCDialog.Action = 1
  115.     strFileName = ctlCDialog.Filename
  116.     If ValidDatabase(strFileName) Then
  117.         SetMousePointer MP_WAIT
  118.         CreateDiagram (strFileName)
  119.         SetMousePointer MP_NORMAL
  120.     Else
  121.         MsgBox "Invalid Database", MB_ICONEXCLAMATION, "Open"
  122.     End If
  123.     Exit Sub
  124. lblFileOpenErr:
  125.     Exit Sub
  126.     Resume Next
  127. End Sub
  128.